package org.example.impl;

import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.annotation.Service;
import org.example.ProviderMainAnno;
import org.example.service.HelloService;

import java.util.concurrent.TimeUnit;


@Service
public class HelloServiceImpl implements HelloService {
    public String sayHello(String name) {
        try {
            java.util.Random random = new java.util.Random();// 定义随机类
            int result = random.nextInt(101);
            TimeUnit.MILLISECONDS.sleep(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
        ProtocolConfig bean = ProviderMainAnno.context.getBean(ProtocolConfig.class);
        return bean.getPort() + ",hello:" + name;
    }

    @Override
    public String methodA() {
        java.util.Random random = new java.util.Random();// 定义随机类
        int result = random.nextInt(101);
        try {
            TimeUnit.MILLISECONDS.sleep(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result + "";
    }

    @Override
    public String methodB() {
        java.util.Random random = new java.util.Random();// 定义随机类
        int result = random.nextInt(101);
        try {
            TimeUnit.MILLISECONDS.sleep(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result + "";
    }

    @Override
    public String methodC() {
        java.util.Random random = new java.util.Random();// 定义随机类
        int result = random.nextInt(101);
        try {
            TimeUnit.MILLISECONDS.sleep(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result + ":毫秒";
    }
}
